home *** CD-ROM | disk | FTP | other *** search
/ New Star Software Collection / NSS_Collection.iso / 3-004 ms visual basic pro 30 / 4.imz / 4.IMA / TABLEOBJ.FR_ / TABLEOBJ.bin
Text File  |  1993-04-28  |  26KB  |  1,012 lines

  1. VERSION 2.00
  2. Begin Form fTableObj 
  3.    BackColor       =   &H00C0C0C0&
  4.    ClientHeight    =   3495
  5.    ClientLeft      =   1335
  6.    ClientTop       =   2625
  7.    ClientWidth     =   5655
  8.    Height          =   3900
  9.    Icon            =   TABLEOBJ.FRX:0000
  10.    KeyPreview      =   -1  'True
  11.    Left            =   1275
  12.    LinkTopic       =   "Form1"
  13.    MDIChild        =   -1  'True
  14.    ScaleHeight     =   3480
  15.    ScaleMode       =   0  'User
  16.    ScaleWidth      =   5675.317
  17.    Tag             =   "Dynaset"
  18.    Top             =   2280
  19.    Width           =   5775
  20.    Begin PictureBox FieldHeader 
  21.       BackColor       =   &H00C0C0C0&
  22.       BorderStyle     =   0  'None
  23.       Height          =   240
  24.       Left            =   0
  25.       ScaleHeight     =   240
  26.       ScaleMode       =   0  'User
  27.       ScaleWidth      =   5028
  28.       TabIndex        =   22
  29.       Top             =   720
  30.       Width           =   5025
  31.       Begin Label FieldValueLabel 
  32.          BackColor       =   &H00C0C0C0&
  33.          Caption         =   " Value  (F4=Zoom) "
  34.          Height          =   255
  35.          Left            =   1680
  36.          TabIndex        =   24
  37.          Top             =   0
  38.          Width           =   3165
  39.       End
  40.       Begin Label FieldHdrLabel 
  41.          BackColor       =   &H00C0C0C0&
  42.          Caption         =   "Field Name:"
  43.          Height          =   252
  44.          Left            =   120
  45.          TabIndex        =   23
  46.          Top             =   0
  47.          Width           =   1212
  48.       End
  49.    End
  50.    Begin PictureBox ViewButtons 
  51.       Align           =   1  'Align Top
  52.       BackColor       =   &H00C0C0C0&
  53.       BorderStyle     =   0  'None
  54.       Height          =   735
  55.       Left            =   0
  56.       ScaleHeight     =   735
  57.       ScaleMode       =   0  'User
  58.       ScaleWidth      =   5658.376
  59.       TabIndex        =   1
  60.       TabStop         =   0   'False
  61.       Top             =   0
  62.       Width           =   5655
  63.       Begin ComboBox cIndexes 
  64.          BackColor       =   &H00FFFFFF&
  65.          Height          =   300
  66.          Left            =   720
  67.          Style           =   2  'Dropdown List
  68.          TabIndex        =   9
  69.          Tag             =   "OL"
  70.          Top             =   360
  71.          Width           =   4335
  72.       End
  73.       Begin CommandButton SeekButton 
  74.          Caption         =   "&Seek"
  75.          Height          =   330
  76.          Left            =   2160
  77.          TabIndex        =   5
  78.          Top             =   0
  79.          Width           =   750
  80.       End
  81.       Begin CommandButton FilterButton 
  82.          Caption         =   "F&ilter"
  83.          Height          =   330
  84.          Left            =   2880
  85.          TabIndex        =   6
  86.          Top             =   0
  87.          Width           =   750
  88.       End
  89.       Begin CommandButton CloseButton 
  90.          Cancel          =   -1  'True
  91.          Caption         =   "&Close"
  92.          Height          =   330
  93.          Left            =   4305
  94.          TabIndex        =   8
  95.          TabStop         =   0   'False
  96.          Top             =   0
  97.          Width           =   750
  98.       End
  99.       Begin CommandButton PropButton 
  100.          Caption         =   "&Prop"
  101.          Height          =   330
  102.          Left            =   3600
  103.          TabIndex        =   7
  104.          Top             =   0
  105.          Width           =   750
  106.       End
  107.       Begin CommandButton DelButton 
  108.          Caption         =   "&Del"
  109.          Height          =   330
  110.          Left            =   1440
  111.          TabIndex        =   4
  112.          Top             =   0
  113.          Width           =   750
  114.       End
  115.       Begin CommandButton EditButton 
  116.          Caption         =   "&Edit"
  117.          Height          =   330
  118.          Left            =   720
  119.          TabIndex        =   3
  120.          Top             =   0
  121.          Width           =   750
  122.       End
  123.       Begin CommandButton AddButton 
  124.          Caption         =   "&Add"
  125.          Height          =   330
  126.          Left            =   0
  127.          TabIndex        =   2
  128.          Top             =   0
  129.          Width           =   750
  130.       End
  131.       Begin Label IndexLabel 
  132.          BackColor       =   &H00C0C0C0&
  133.          Caption         =   "Index:"
  134.          Height          =   255
  135.          Left            =   120
  136.          TabIndex        =   25
  137.          Top             =   400
  138.          Width           =   615
  139.       End
  140.    End
  141.    Begin PictureBox ChangeButtons 
  142.       BackColor       =   &H00C0C0C0&
  143.       BorderStyle     =   0  'None
  144.       Height          =   690
  145.       Left            =   0
  146.       ScaleHeight     =   690
  147.       ScaleMode       =   0  'User
  148.       ScaleWidth      =   5658.376
  149.       TabIndex        =   14
  150.       TabStop         =   0   'False
  151.       Top             =   0
  152.       Visible         =   0   'False
  153.       Width           =   5655
  154.       Begin CommandButton UpdateButton 
  155.          Caption         =   "&Update"
  156.          Height          =   372
  157.          Left            =   960
  158.          TabIndex        =   16
  159.          Top             =   48
  160.          Width           =   1212
  161.       End
  162.       Begin CommandButton CancelButton 
  163.          Caption         =   "&Cancel"
  164.          Height          =   372
  165.          Left            =   2640
  166.          TabIndex        =   15
  167.          Top             =   48
  168.          Width           =   1212
  169.       End
  170.    End
  171.    Begin PictureBox StatBox 
  172.       Align           =   2  'Align Bottom
  173.       BackColor       =   &H00C0C0C0&
  174.       BorderStyle     =   0  'None
  175.       Height          =   281
  176.       Left            =   0
  177.       ScaleHeight     =   298.153
  178.       ScaleMode       =   0  'User
  179.       ScaleWidth      =   5665.189
  180.       TabIndex        =   20
  181.       TabStop         =   0   'False
  182.       Top             =   3210
  183.       Width           =   5655
  184.       Begin CommandButton NextButton 
  185.          Caption         =   ">"
  186.          FontBold        =   -1  'True
  187.          FontItalic      =   0   'False
  188.          FontName        =   "MS Sans Serif"
  189.          FontSize        =   12
  190.          FontStrikethru  =   0   'False
  191.          FontUnderline   =   0   'False
  192.          Height          =   287
  193.          Left            =   4200
  194.          TabIndex        =   12
  195.          Top             =   0
  196.          Width           =   375
  197.       End
  198.       Begin CommandButton LastButton 
  199.          Caption         =   ">|"
  200.          FontBold        =   -1  'True
  201.          FontItalic      =   0   'False
  202.          FontName        =   "MS Sans Serif"
  203.          FontSize        =   12
  204.          FontStrikethru  =   0   'False
  205.          FontUnderline   =   0   'False
  206.          Height          =   287
  207.          Left            =   4575
  208.          TabIndex        =   13
  209.          Top             =   0
  210.          Width           =   375
  211.       End
  212.       Begin CommandButton FirstButton 
  213.          Caption         =   "|<"
  214.          FontBold        =   -1  'True
  215.          FontItalic      =   0   'False
  216.          FontName        =   "MS Sans Serif"
  217.          FontSize        =   12
  218.          FontStrikethru  =   0   'False
  219.          FontUnderline   =   0   'False
  220.          Height          =   287
  221.          Left            =   0
  222.          TabIndex        =   10
  223.          Top             =   0
  224.          Width           =   375
  225.       End
  226.       Begin CommandButton PrevButton 
  227.          Caption         =   "<"
  228.          FontBold        =   -1  'True
  229.          FontItalic      =   0   'False
  230.          FontName        =   "MS Sans Serif"
  231.          FontSize        =   12
  232.          FontStrikethru  =   0   'False
  233.          FontUnderline   =   0   'False
  234.          Height          =   287
  235.          Left            =   375
  236.          TabIndex        =   11
  237.          Top             =   0
  238.          Width           =   375
  239.       End
  240.       Begin Label cStatusBar 
  241.          BackColor       =   &H00FFFFFF&
  242.          BorderStyle     =   1  'Fixed Single
  243.          Height          =   285
  244.          Left            =   735
  245.          TabIndex        =   21
  246.          Top             =   0
  247.          Width           =   3360
  248.       End
  249.    End
  250.    Begin VScrollBar cScrollBar 
  251.       Height          =   2616
  252.       LargeChange     =   3000
  253.       Left            =   5040
  254.       SmallChange     =   300
  255.       TabIndex        =   19
  256.       Top             =   960
  257.       Visible         =   0   'False
  258.       Width           =   252
  259.    End
  260.    Begin PictureBox cFields 
  261.       BackColor       =   &H00C0C0C0&
  262.       BorderStyle     =   0  'None
  263.       Height          =   375
  264.       Left            =   120
  265.       ScaleHeight     =   372
  266.       ScaleMode       =   0  'User
  267.       ScaleWidth      =   4812
  268.       TabIndex        =   17
  269.       TabStop         =   0   'False
  270.       Top             =   960
  271.       Width           =   4815
  272.       Begin TextBox cFieldData 
  273.          BackColor       =   &H00FFFFFF&
  274.          DataSource      =   "Data1"
  275.          ForeColor       =   &H00000000&
  276.          Height          =   288
  277.          Index           =   0
  278.          Left            =   1560
  279.          TabIndex        =   0
  280.          Top             =   0
  281.          Visible         =   0   'False
  282.          Width           =   3252
  283.       End
  284.       Begin Label cFieldName 
  285.          BackColor       =   &H00C0C0C0&
  286.          ForeColor       =   &H00000000&
  287.          Height          =   252
  288.          Index           =   0
  289.          Left            =   0
  290.          TabIndex        =   18
  291.          Top             =   60
  292.          Visible         =   0   'False
  293.          Width           =   1572
  294.       End
  295.    End
  296. End
  297. Option Explicit
  298.  
  299. 'form variables
  300. Dim FTBL As Table             'current form's table
  301. Dim FTblName As String        'form dynaset table name
  302. Dim FBM As String             'form bookmark
  303. Dim FNotFound As Integer      'used by find function
  304. Dim FAtTop As Integer         'top flag
  305. Dim FEditFlag As Integer      'edit mode
  306. Dim FAddNewFlag As Integer    'add mode
  307. Dim FFldDataChanged As Integer
  308. Dim FSeekForm As New fSeek    'seek form instance
  309. Dim FCurrRec As Integer       'record counter
  310. Dim FNumbRows As Long         'total rows in Table
  311.  
  312. Sub AddButton_Click ()
  313.   On Error GoTo AddErr
  314.  
  315.   'set the mode
  316.   FTBL.AddNew
  317.   cStatusBar = "Add record"
  318.   FAddNewFlag = True
  319.   If FTBL.RecordCount > 0 Then
  320.     FBM = FTBL.Bookmark
  321.   Else
  322.     FBM = ""
  323.   End If
  324.  
  325.   ChangeButtons.Visible = True
  326.   ViewButtons.Visible = False
  327.   NextButton.Enabled = False
  328.   FirstButton.Enabled = False
  329.   LastButton.Enabled = False
  330.   PrevButton.Enabled = False
  331.  
  332.   ClearDataFields
  333.   cFieldData(0).SetFocus
  334.   GoTo AddEnd
  335.  
  336. AddErr:
  337.   ShowError
  338.   Resume AddEnd
  339.  
  340. AddEnd:
  341.  
  342. End Sub
  343.  
  344. Sub CancelButton_Click ()
  345.    On Error Resume Next
  346.  
  347.    ChangeButtons.Visible = False
  348.    ViewButtons.Visible = True
  349.    NextButton.Enabled = True
  350.    FirstButton.Enabled = True
  351.    LastButton.Enabled = True
  352.    PrevButton.Enabled = True
  353.  
  354.    FEditFlag = False
  355.    FAddNewFlag = False
  356.    If FBM <> "" Then FTBL.Bookmark = FBM
  357.    DisplayCurrentRecord
  358.  
  359. End Sub
  360.  
  361. Sub cFieldData_Change (Index As Integer)
  362.   'just set the flag if data is changed
  363.   'it gets reset to false when a new record is displayed
  364.   FFldDataChanged = True
  365. End Sub
  366.  
  367. Sub cFieldData_KeyDown (Index As Integer, KeyCode As Integer, Shift As Integer)
  368.   If KeyCode = &H73 Then   'F4
  369.     cFieldName_DblClick Index
  370.  
  371.   ElseIf KeyCode = 34 And cScrollBar.Visible = True Then
  372.     'pagedown with > 10 fields
  373.     cScrollBar = cScrollBar - 3000
  374.  
  375.   ElseIf KeyCode = 33 And cScrollBar.Visible = True Then
  376.     'pageup with > 10 fields
  377.     cScrollBar = cScrollBar + 3000
  378.  
  379.   End If
  380. End Sub
  381.  
  382. Sub cFieldData_KeyPress (Index As Integer, KeyAscii As Integer)
  383.   'only allow return when in edit of add mode
  384.   If FEditFlag = True Or FAddNewFlag = True Then
  385.     If FTBL(Index).Type = FT_STRING And Len(cFieldData(Index)) > FTBL(Index).Size Then
  386.       Beep
  387.       MsgBox "Field Length Exceeded!", 48
  388.       KeyAscii = 0
  389.       Exit Sub
  390.     End If
  391.     If KeyAscii = 13 Then
  392.       KeyAscii = 0
  393.       SendKeys "{Tab}"
  394.     End If
  395.  
  396.   'throw away the keystrokes if not in add or edit mode
  397.   ElseIf FEditFlag = False And FAddNewFlag = False Then
  398.     KeyAscii = 0
  399.   End If
  400.  
  401. End Sub
  402.  
  403. Sub cFieldData_LostFocus (Index As Integer)
  404.   On Error GoTo FldDataErr
  405.  
  406.   If FFldDataChanged = True Then
  407.     'store the data in the field
  408.     FTBL(Index) = cFieldData(Index)
  409.   End If
  410.  
  411.   GoTo FldDataEnd
  412.  
  413. FldDataErr:
  414.   ShowError
  415.   Resume FldDataEnd
  416.  
  417. FldDataEnd:
  418.   'reset for valid or error condition
  419.   FFldDataChanged = False
  420.  
  421. End Sub
  422.  
  423. Sub cFieldName_DblClick (Index As Integer)
  424.   On Error GoTo ZoomErr
  425.  
  426.   If FTBL(Index).Type = FT_STRING Or FTBL(Index).Type = FT_MEMO Then
  427.      If FTBL(Index).FieldSize() < GETCHUNK_CUTOFF Then
  428.        gstZoomData = cFieldData(Index)
  429.      Else
  430.        'add the rest of the field data with getchunk
  431.        MsgBar "Getting Memo Field Data", True
  432.        SetHourglass Me
  433.        gstZoomData = cFieldData(Index) + StripNonAscii(FTBL(Index).GetChunk(GETCHUNK_CUTOFF, MAX_MEMO_SIZE))
  434.        ResetMouse Me
  435.        MsgBar "", False
  436.      End If
  437.      fZoom.Caption = Mid(cFieldName(Index), 1, Len(cFieldName(Index)) - 1)
  438.      fZoom.Top = Top + 1200
  439.      fZoom.Left = Left + 250
  440.      If FAddNewFlag Or FEditFlag Then
  441.        fZoom.SaveButton.Visible = True
  442.        fZoom.CloseButton.Visible = True
  443.      Else
  444.        fZoom.CloseZoomButton.Visible = True
  445.      End If
  446.      fZoom.Show MODAL
  447.      If FAddNewFlag Or FEditFlag Then
  448.        If FTBL(Index).Type = FT_STRING And Len(gstZoomData) > FTBL(Index).Size Then
  449.          Beep
  450.          MsgBox "Field Length Exceeded, Data Truncated!", 48
  451.          cFieldData(Index) = Mid(gstZoomData, 1, FTBL(Index).Size)
  452.        Else
  453.          cFieldData(Index) = gstZoomData
  454.        End If
  455.        FTBL(Index) = cFieldData(Index)
  456.        FFldDataChanged = False
  457.      End If
  458.   End If
  459.   GoTo ZoomEnd
  460.  
  461. ZoomErr:
  462.   ShowError
  463.   Resume ZoomEnd
  464.  
  465. ZoomEnd:
  466.  
  467. End Sub
  468.  
  469. Sub cIndexes_Click ()
  470.   On Error GoTo IndErr
  471.  
  472.   If FTBL Is Nothing Then Exit Sub
  473.   If FTBL.Index = Mid(cIndexes, 1, InStr(1, cIndexes, ":") - 1) Then Exit Sub
  474.  
  475.   FTBL.Index = Mid(cIndexes, 1, InStr(1, cIndexes, ":") - 1)
  476.   FCurrRec = 1
  477.   DisplayCurrentRecord
  478.   FAtTop = True
  479.  
  480.   GoTo IndEnd
  481.  
  482. IndErr:
  483.   ShowError
  484.   Resume IndEnd
  485.  
  486. IndEnd:
  487.  
  488. End Sub
  489.  
  490. Sub ClearDataFields ()
  491.   Dim i As Integer
  492.  
  493.   'clear out the fields on the main form
  494.   For i = 0 To FTBL.Fields.Count - 1
  495.     cFieldData(i) = ""
  496.   Next
  497. End Sub
  498.  
  499. Sub CloseButton_Click ()
  500.   Unload Me
  501. End Sub
  502.  
  503. Sub cScrollBar_Change ()
  504.   Dim t As Integer
  505.  
  506.   t = cScrollBar
  507.   If (t - 960) Mod 300 = 0 Then
  508.     cFields.Top = t
  509.   Else
  510.     cFields.Top = ((t - 960) \ 300) * 300 + 960
  511.   End If
  512.  
  513. End Sub
  514.  
  515. Sub DelButton_Click ()
  516.   On Error GoTo DelRecErr
  517.  
  518.   If MsgBox("Delete Current Record?", MSGBOX_TYPE) = YES Then
  519.     FTBL.Delete
  520.     If gfTransPending Then gfDBChanged = True
  521.     If FTBL.EOF = False Then
  522.       FTBL.MoveNext
  523.     End If
  524.     FNumbRows = FNumbRows - 1
  525.     DisplayCurrentRecord
  526.   End If
  527.  
  528.   GoTo DelRecEnd
  529.  
  530. DelRecErr:
  531.   ShowError
  532.   Resume DelRecEnd
  533.  
  534. DelRecEnd:
  535.  
  536. End Sub
  537.  
  538. Sub DisplayCurrentRecord ()
  539.    Dim i As Integer
  540.    Dim cst As String    'current status bar
  541.    Dim currstr As String
  542.  
  543.    On Error GoTo DCRErr
  544.  
  545.    SetHourglass Me
  546.  
  547.    If FCurrRec = -1 And FTBL.RecordCount = 0 Then
  548.      currstr = "?"
  549.    Else
  550.      currstr = CStr(FCurrRec)
  551.    End If
  552.    cst = "Record "
  553.    'check BOF/EOF flag so we know if we
  554.    'are sitting on a valid record
  555.    If FAddNewFlag = True Then
  556.      cst = cst + currstr + " of " + CStr(FNumbRows)
  557.    Else
  558.      If FTBL.BOF = True Then
  559.        FCurrRec = 0
  560.        cst = cst + "(BOF) of " + CStr(FNumbRows)
  561.        ClearDataFields
  562.      ElseIf FTBL.EOF = True Then
  563.        FCurrRec = FNumbRows + 1
  564.        cst = cst + "(EOF) of " + CStr(FNumbRows)
  565.        ClearDataFields
  566.      Else
  567.        cst = cst + currstr + " of " + CStr(FNumbRows)
  568.        'place the data in the form fields
  569.        For i = 0 To FTBL.Fields.Count - 1
  570.          If FTBL(i).Type = FT_MEMO Then
  571.            If FTBL(i).FieldSize() < GETCHUNK_CUTOFF Then
  572.              cFieldData(i) = StripNonAscii(vFieldVal(FTBL(i)))
  573.            Else
  574.              cFieldData(i) = StripNonAscii(vFieldVal(FTBL(i).GetChunk(0, GETCHUNK_CUTOFF)))
  575.            End If
  576.          ElseIf FTBL(i).Type = FT_STRING Then
  577.            cFieldData(i) = StripNonAscii(vFieldVal(FTBL(i)))
  578.          Else
  579.            cFieldData(i) = vFieldVal(FTBL(i))
  580.          End If
  581.        Next
  582.      End If
  583.    End If
  584.    If gfUpdatable = False Then cst = cst + "  [Not Updatable]"
  585.    cStatusBar = cst
  586.    'set the flag
  587.    FFldDataChanged = False
  588.  
  589.    GoTo DCREnd
  590.  
  591. DCRErr:
  592.   ShowError
  593.   Resume DCREnd
  594.  
  595. DCREnd:
  596.    ResetMouse Me
  597.  
  598. End Sub
  599.  
  600. Sub EditButton_Click ()
  601.    On Error GoTo EditErr
  602.  
  603.    FTBL.Edit
  604.    cStatusBar = "Edit record"
  605.    FEditFlag = True
  606.    cFieldData(0).SetFocus
  607.    FBM = FTBL.Bookmark
  608.  
  609.    ChangeButtons.Visible = True
  610.    ViewButtons.Visible = False
  611.    NextButton.Enabled = False
  612.    FirstButton.Enabled = False
  613.    LastButton.Enabled = False
  614.    PrevButton.Enabled = False
  615.    GoTo EditEnd
  616.  
  617. EditErr:
  618.   ShowError
  619.   Resume EditEnd
  620.  
  621. EditEnd:
  622.  
  623. End Sub
  624.  
  625. Sub FilterButton_Click ()
  626.   On Error GoTo FilterErr
  627.  
  628.   Dim FilterStr As String
  629.   Dim f As New fDynaset
  630.  
  631.   FilterStr = InputBox("Enter Filter Expression:")
  632.   If FilterStr = "" Then Exit Sub
  633.  
  634.   gstTableDynaFilter = "select * from " + FTblName + " where " + FilterStr
  635.   f.Show                           'open dynaset form w/ filtered table
  636.   gstTableDynaFilter = ""
  637.   GoTo FilterEnd
  638.  
  639. FilterErr:
  640.   ShowError
  641.   Resume FilterEnd
  642.  
  643. FilterEnd:
  644.  
  645. End Sub
  646.  
  647. Sub FirstButton_Click ()
  648.    Dim ds As String
  649.    On Error GoTo GoFirstError
  650.  
  651.    FTBL.MoveFirst
  652.    FCurrRec = 1
  653.    DisplayCurrentRecord
  654.    FAtTop = True
  655.  
  656.    GoTo GoFirstEnd
  657.  
  658. GoFirstError:
  659.    ShowError
  660.    Resume GoFirstEnd
  661.  
  662. GoFirstEnd:
  663.    ResetMouse Me
  664.    MsgBar "", False
  665.  
  666. End Sub
  667.  
  668. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  669.   If FEditFlag = True Or FAddNewFlag = True Then Exit Sub
  670.   
  671.   Select Case KeyCode
  672.     Case 35                'end
  673.       Call LastButton_Click
  674.     Case 36                'home
  675.       Call FirstButton_Click
  676.     Case 38                'up arrow
  677.       If Shift = 2 Then
  678.         Call FirstButton_Click
  679.       Else
  680.         Call PrevButton_Click
  681.       End If
  682.     Case 40                'down arrow
  683.       If Shift = 2 Then
  684.         Call LastButton_Click
  685.       Else
  686.         Call NextButton_Click
  687.       End If
  688.  
  689.   End Select
  690.  
  691. End Sub
  692.  
  693. Sub Form_Load ()
  694.    Dim ft As Integer
  695.    Dim i As Integer
  696.    Dim tbl As tabledef
  697.    Dim istr As String
  698.  
  699.    On Error GoTo TableErr
  700.  
  701.    SetHourglass Me
  702.    MsgBar "Opening Table", True
  703.  
  704.    FTblName = fTables.cTableList
  705.    Set tbl = gCurrentDB.TableDefs(FTblName)
  706.    For i = 0 To tbl.Indexes.Count - 1
  707.      istr = tbl.Indexes(i).Name
  708.      istr = istr + ":" + tbl.Indexes(i).Fields
  709.      If tbl.Indexes(i).Unique = True Then
  710.        istr = istr + ":Unique"
  711.      Else
  712.        istr = istr + ":Non-Unique"
  713.      End If
  714.      If tbl.Indexes(i).Primary = True Then
  715.        istr = istr + ":Primary"
  716.      End If
  717.      cIndexes.AddItem istr
  718.    Next
  719.    Set FTBL = gCurrentDB.OpenTable(FTblName)
  720.  
  721.    'show the first record
  722.    FNumbRows = GetNumbRecsTbl(FTBL)          'query numb of recs
  723.  
  724.    'load the controls on the Table form
  725.    cFieldName(0).Visible = True
  726.    cFieldData(0).Visible = True
  727.    ft = FTBL(0).Type
  728.    cFieldData(0).Width = GetFieldWidth(ft)
  729.    cFieldData(0).TabIndex = 0
  730.    For i = 1 To FTBL.Fields.Count - 1
  731.      cFields.Height = cFields.Height + 300
  732.      Load cFieldName(i)
  733.      cFieldName(i).Top = cFieldName(i - 1).Top + 300
  734.      cFieldName(i).Visible = True
  735.      Load cFieldData(i)
  736.      cFieldData(i).Top = cFieldData(i - 1).Top + 300
  737.      cFieldData(i).Visible = True
  738.      ft = FTBL.Fields(i).Type
  739.      cFieldData(i).Width = GetFieldWidth(ft)
  740.      cFieldData(i).TabIndex = i
  741.    Next
  742.  
  743.    'resize main window
  744.    If i <= 10 Then
  745.      Height = ((i + 1) * 300) + 1600
  746.    Else
  747.      Height = 4668
  748.      Width = Width + 260
  749.      cScrollBar.Visible = True
  750.      cScrollBar.Min = 900
  751.      cScrollBar.Max = 900 - (i * 300) + 3000
  752.    End If
  753.  
  754.    'display the field names
  755.    For i = 0 To FTBL.Fields.Count - 1
  756.      cFieldName(i) = UCase(FTBL(i).Name) + ":"
  757.    Next
  758.  
  759.    FCurrRec = 1
  760.    If cIndexes.ListCount > 0 Then
  761.      cIndexes.ListIndex = 0
  762.    End If
  763.    DisplayCurrentRecord      'display field values
  764.    FAtTop = True
  765.  
  766.    Caption = "Table: " + FTblName
  767.    Width = 5805
  768.    Left = 1000
  769.    Top = 1000
  770.    
  771.    GoTo OkayEnd
  772.  
  773. TableErr:
  774.    ShowError
  775.    ResetMouse Me
  776.    Unload Me
  777.    MsgBar "", False
  778.    Exit Sub
  779.    Resume OkayEnd
  780.  
  781. OkayEnd:
  782.    ResetMouse Me
  783.    MsgBar "", False
  784.  
  785. End Sub
  786.  
  787. Sub Form_Paint ()
  788.   Outlines Me
  789. End Sub
  790.  
  791. Sub Form_Resize ()
  792.   On Error Resume Next
  793.  
  794.   Dim h As Integer, i As Integer
  795.   Dim totw As Integer
  796.  
  797.   If WindowState <> 1 Then   'not minimized
  798.     MsgBar "Resizing Form", True
  799.     'make sure the form is lined up on a field
  800.     h = Height
  801.     If (h - 1660) Mod 300 <> 0 Then
  802.       Height = ((h - 1660) \ 300) * 300 + 1660
  803.     End If
  804.     'resize the status bar
  805.     StatBox.Top = Height - 650
  806.     'resize the scrollbar
  807.     cScrollBar.Height = StatBox.Top - (ViewButtons.Top - FieldHeader.Height) - 1200
  808.     cScrollBar.Left = Width - 360
  809.     If FTBL.Fields.Count > 10 Then
  810.       cFields.Width = Width - 260
  811.       totw = cScrollBar.Left - 20
  812.     Else
  813.       cFields.Width = Width - 20
  814.       totw = Width - 50
  815.     End If
  816.     FieldHeader.Width = Width - 20
  817.     'widen the fields if possible
  818.     For i = 0 To FTBL.Fields.Count - 1
  819.       cFieldName(i).Width = .3 * totw
  820.       cFieldData(i).Left = cFieldName(i).Width + 20
  821.       If FTBL(i).Type = FT_STRING Or FTBL(i).Type = FT_MEMO Then
  822.         cFieldData(i).Width = .7 * totw - 250
  823.       End If
  824.     Next
  825.     FieldValueLabel.Left = cFieldData(0).Left
  826.     cStatusBar.Width = Width - 1600
  827.     NextButton.Left = cStatusBar.Width + 745
  828.     LastButton.Left = NextButton.Left + 370
  829.   End If
  830.   MsgBar "", False
  831. End Sub
  832.  
  833. Sub Form_Unload (Cancel As Integer)
  834.   On Error Resume Next
  835.  
  836.   Unload FSeekForm   'get rid of attached seek form
  837.   FTBL.Close          'close the form Table
  838.   MsgBar "", False
  839. End Sub
  840.  
  841. Sub LastButton_Click ()
  842.    On Error GoTo GoLastError
  843.  
  844.    FTBL.MoveLast
  845.    'show the current record
  846.    FCurrRec = FNumbRows
  847.    DisplayCurrentRecord
  848.  
  849.    GoTo GoLastEnd
  850.  
  851. GoLastError:
  852.    ShowError
  853.    Resume GoLastEnd
  854.  
  855. GoLastEnd:
  856.  
  857. End Sub
  858.  
  859. Sub NextButton_Click ()
  860.    On Error GoTo GoNextError
  861.  
  862.    FTBL.MoveNext
  863.    'show the current record
  864.    If FCurrRec <> -1 Then
  865.      FCurrRec = FCurrRec + 1   'bump the record counter
  866.    End If
  867.    DisplayCurrentRecord
  868.    FAtTop = False
  869.  
  870.    GoTo GoNextEnd
  871.  
  872. GoNextError:
  873.    ShowError
  874.    Resume GoNextEnd
  875.  
  876. GoNextEnd:
  877.  
  878. End Sub
  879.  
  880. Sub PrevButton_Click ()
  881.    On Error GoTo GoPrevError
  882.  
  883.    FTBL.MovePrevious
  884.    'show the current record
  885.    If FCurrRec <> -1 Then
  886.      FCurrRec = FCurrRec - 1   'bump the record counter back
  887.    End If
  888.    DisplayCurrentRecord
  889.    FAtTop = False
  890.  
  891.    GoTo GoPrevEnd
  892.  
  893. GoPrevError:
  894.    ShowError
  895.    Resume GoPrevEnd
  896.  
  897. GoPrevEnd:
  898.  
  899. End Sub
  900.  
  901. Sub PropButton_Click ()
  902.    Dim f As New fDataBox
  903.  
  904.    On Error GoTo DynPropErr
  905.  
  906.    Set gCurrentTbl = FTBL
  907.    f.Caption = "Table Properties"
  908.    f.Tag = "TBL"
  909.  
  910.    f.cData.AddItem "Name = " + FTBL.Name
  911.    f.cData.AddItem "BOF Flag = " + stTrueFalse((FTBL.BOF))
  912.    f.cData.AddItem "BookMark = " + FTBL.Bookmark
  913.    f.cData.AddItem "BookMarkable Flag = " + stTrueFalse((FTBL.Bookmarkable))
  914.    f.cData.AddItem "Date Created = " + FTBL.DateCreated
  915.    f.cData.AddItem "EOF Flag = " + stTrueFalse((FTBL.EOF))
  916.    f.cData.AddItem "Index = " + FTBL.Index
  917.    f.cData.AddItem "Last Modified = " + FTBL.LastModified
  918.    f.cData.AddItem "Last Updated = " + FTBL.LastUpdated
  919.    f.cData.AddItem "Lock Edits Flag = " + stTrueFalse((FTBL.LockEdits))
  920.    f.cData.AddItem "No Match Flag = " + stTrueFalse((FTBL.NoMatch))
  921.    f.cData.AddItem "Transactions Flag = " + stTrueFalse((FTBL.Transactions))
  922.    f.cData.AddItem "RecordCount = " & FTBL.RecordCount
  923.    f.cData.AddItem "Updatable Flag = " + stTrueFalse((FTBL.Updatable))
  924.  
  925.    f.Show MODAL
  926.  
  927.   GoTo DynPropEnd
  928.  
  929. DynPropErr:
  930.   f.cData.AddItem Error$
  931.   Resume Next
  932.  
  933. DynPropEnd:
  934.  
  935. End Sub
  936.  
  937. Sub SeekButton_Click ()
  938.   On Error GoTo SeekErr
  939.   Dim bm As String
  940.  
  941.   If FTBL.RecordCount = 0 Then Exit Sub
  942.  
  943. SeekStart:
  944.   MsgBar "Enter Seek Parameters", False
  945.   fSeek.Show MODAL
  946.   If gstSeekValue = "" Then GoTo SeekEnd
  947.  
  948.   bm = FTBL.Bookmark
  949.  
  950.   SetHourglass Me
  951.   FTBL.Seek gstSeekOperator, gstSeekValue
  952.   ResetMouse Me
  953.  
  954.   'return to old record if no match was found
  955.   If FTBL.NoMatch And bm <> "" Then
  956.     Beep
  957.     MsgBox "Record Not Found", 48
  958.     FTBL.Bookmark = bm
  959.     GoTo SeekStart
  960.   Else
  961.     If FCurrRec <> -1 Then
  962.       MsgBox "Current Record Number cannot be retained after Seek!"
  963.     End If
  964.     FCurrRec = -1  'set to -1 because it is no longer valid
  965.   End If
  966.  
  967.   DisplayCurrentRecord
  968.   GoTo SeekEnd
  969.  
  970. SeekErr:
  971.   ResetMouse Me
  972.   MsgBox Error$
  973.   Resume SeekEnd
  974.  
  975. SeekEnd:
  976.   MsgBar "", False
  977.   
  978. End Sub
  979.  
  980. Sub UpdateButton_Click ()
  981.   On Error GoTo UpdateErr
  982.  
  983.   FTBL.Update
  984.   If gfTransPending Then gfDBChanged = True
  985.  
  986.   If FAddNewFlag = True Then
  987.     FNumbRows = FNumbRows + 1
  988.     FCurrRec = FNumbRows
  989.     FTBL.MoveLast               'move to the new record
  990.   End If
  991.  
  992.   FEditFlag = False
  993.   FAddNewFlag = False
  994.   ChangeButtons.Visible = False
  995.   ViewButtons.Visible = True
  996.   NextButton.Enabled = True
  997.   FirstButton.Enabled = True
  998.   LastButton.Enabled = True
  999.   PrevButton.Enabled = True
  1000.   DisplayCurrentRecord
  1001.  
  1002.   GoTo UpdateEnd
  1003.  
  1004. UpdateErr:
  1005.   ShowError
  1006.   Resume UpdateEnd
  1007.  
  1008. UpdateEnd:
  1009.  
  1010. End Sub
  1011.  
  1012.